'use strict';

module.exports = async (ctx) => {
  const axios = require('axios');
  let loginCode = ctx.args.code;
  let appId = 'wxbc3cce50edc7a575';   //小程序appid
  let appSecret = 'a3135db1fc1e6e0c2d74430eca28f032';
  //请求api获取openId
  let openId = await axios.get('https://api.weixin.qq.com/sns/jscode2session?appid=' + appId + '&secret=' + appSecret + '&js_code=' + loginCode + '&grant_type=authorization_code');
  return openId.data.openid;
}
